package marmalius.quest;

import marmalius.Player;
import marmalius.client;

public class Tutorial extends BaseQuest {
	private static int MAXSTATUS = 10;
	private static QuestID questID = QuestID.TUTORIAL;
	
	/*
	 * Tutorial :
	 * 0 -> Skin Select
	 * 1 -> First Dialogue with 'RuneScape Guide'
	 * 2 -> 
	 */
	
	public boolean isAlreadyDone(Player player) {
		return player.getQuestStatus(questID) >= MAXSTATUS;
	}

	public boolean talkToNPC(Player player, int npcID) {
		switch (npcID) {
			case 945: //RuneScape Guide
				if (player.getQuestStatus(questID) == 1) {
					player.setDialogID(1);
					((client)player).sendNpcChat2(
						"Greetings! I see you are a new arrival to this land. My",
						"job is to welcome all new visitors. So welcome!",
						945, 
						"RuneScape Guide"
					);
					return true;
				}
				
				break;
		}
		return false;
	}
	
	public boolean autoTalkToNPC(Player player) {
		switch (player.getDialogNpcID()) {
			case 945: //RuneScape Guide
				if (player.getQuestStatus(questID) == 1) {
					if (player.getDialogID() == 1) {
						player.setDialogID(2);
						((client)player).sendNpcChat2(
							"You have already learned the first thing needed to",
							"succeed in this world: talking to other people!",
							945, 
							"RuneScape Guide"
						);
						return true;
					}
					if (player.getDialogID() == 2) {
						player.setDialogID(3);
						((client)player).sendNpcChat3(
							"You will find many inhabitants of this world have useful",
							"things to say to you. By clicking on them with your",
							"mouse you can talk to them.",
							945, 
							"RuneScape Guide"
						);
						return true;
					}
					if (player.getDialogID() == 3) {
						player.setDialogID(4);
						((client)player).sendNpcChat4(
							"I would also suggest reading through some of the",
							"supporting information on the website. There you can",
							"fin the knowledge Base, which contains all the",
							"additional information you're ever likely to need. It also",
							945,
							"RuneScape Guide"
						);
						return true;
					}
					if (player.getDialogID() == 4) {
						player.setDialogID(5);
						((client)player).sendNpcChat2(
							"contains maps and helpful tips to help you on your",
							"journey.",
							945,
							"RuneScape Guide"
						);
						return true;
					}
					if (player.getDialogID() == 5) {
						player.setDialogID(6);
						((client)player).sendNpcChat2(
							"You will notice a flashing icon of a spanner, please click",
							"on this to continue the tutorial.",
							945,
							"RuneScape Guide"
						);
						return true;
					}
					if (player.getDialogID() == 6) { //il faut faire flasher le control user et afficher en boucle ce message jusqu'a ce qu'il clique
						player.setQuestStatus(questID, 2);
						player.resetDialog();
						
						return true;
					}
				}
				
				break;
		}
		return false;
	}
	
	public void process(Player player) {
		if (player.getQuestStatus(questID) <= 0 && !player.isDialog())
			((client)player).showInterface(3559); //Skin Dialogue
		else if (player.getQuestStatus(questID) == 1 && !player.isDialog()) {
			((client)player).sendStartInfo(
				"To start the tutorial use your left mouse button to click on the",
				"RuneScape Guide in this room. He is indicated by a flashing",
				"yellow arrow above his head. If you can't see him, use your",
				"keyboard's arrow keys to rotate the view.",
				"Getting started"
			);
		}
		else if (player.getQuestStatus(questID) == 2 && !player.isDialog()) {
			((client)player).setSidebarInterface(12, 147); //Player Controls
			//((client)player).flashSideBarIcon(12); //don't work
			((client)player).sendStartInfo(
				"Player controls",
				"Please click on the flashing spanner icon found at the bottom",
				"right of your screen. This will display your player controls.",
				"",
				""
			);
		}
			
	}
	
	public void playerLogIn(Player player) { //player log in
		switch (player.getQuestStatus(questID)) {
			case 0:
			case 1:
				((client)player).setSidebarInterface(0, -1); //combat
				((client)player).setSidebarInterface(1, -1); //stat
				((client)player).setSidebarInterface(2, -1); //Quest
				((client)player).setSidebarInterface(3, -1); //inventory
				((client)player).setSidebarInterface(4, -1); //wear stuff
				((client)player).setSidebarInterface(5, -1); //Prayer
				((client)player).setSidebarInterface(6, -1); //Spell
				//((client)player).setSidebarInterface(7, 18128); // ?
				((client)player).setSidebarInterface(8, -1); //Friends
				((client)player).setSidebarInterface(9, -1); //Ignore
				//((client)player).setSidebarInterface(10, 2449); // ?
				((client)player).setSidebarInterface(11, -1); //Option
				((client)player).setSidebarInterface(12, -1); //Player Controls
				((client)player).setSidebarInterface(13, -1); //Music
				break;
			case 2:
				((client)player).setSidebarInterface(0, -1);
				((client)player).setSidebarInterface(1, -1);
				((client)player).setSidebarInterface(2, -1);
				((client)player).setSidebarInterface(3, -1);
				((client)player).setSidebarInterface(4, -1);
				((client)player).setSidebarInterface(5, -1);
				((client)player).setSidebarInterface(6, -1);
				((client)player).setSidebarInterface(8, -1);
				((client)player).setSidebarInterface(9, -1);
				((client)player).setSidebarInterface(11, -1);
				((client)player).setSidebarInterface(12, 147); //Player Controls
				((client)player).setSidebarInterface(13, -1);
				break;
		}
	}
	
	public void questEvent(Player player, QuestEvent questEvent) {
		switch (questEvent) {
			case SKINEDIT:
				player.setQuestStatus(questID, 1);
				process(player);
				break;
		}
	}
	
	public static void tutorial0(Player player) { //TODO delete
		//player.setTeleport(3093, 3106, 0); //zone de depart
	}

}
